Skip to content

Fixing AES encryptor cache - fix by argmarco#91

Merged
sofia-tekdatum merged 4 commits intodev_phase2from
fix_encryptor_cache
Aug 26, 2025
Merged

Fixing AES encryptor cache - fix by argmarco#91
sofia-tekdatum merged 4 commits intodev_phase2from
fix_encryptor_cache

Conversation

@sofia-tekdatum
Copy link
Collaborator

Adding fix by argmarco to the AES encryptor cache.

Small modification from his original fix -- including the write length in the key and modifying how the write length was sent caused all tests to fail.

Tests currently passing (all encryption-related tests).

@github-actions
Copy link

Thanks for opening a pull request!

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

See also:

Copy link
Collaborator

@avalerio-tkd avalerio-tkd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a few questions to clarify.

uint64_t AesEncryptorFactory::MakeCacheKey(
ParquetCipher::type alg_id, int32_t key_len, bool metadata) {
uint64_t key = 0;
key |= static_cast<uint64_t>(static_cast<uint32_t>(alg_id)) << 32;
Copy link
Collaborator

@avalerio-tkd avalerio-tkd Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I absolutely love this!

Let's just add a comment for each bit encoded field.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

ParquetCipher::type alg_id, int32_t key_size) {
auto key_len = static_cast<int32_t>(key_size);
int index = MapKeyLenToEncryptorArrayIndex(key_len);
uint64_t cache_key = MakeCacheKey(alg_id, key_len, /*metadata=*/true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the last param commented out? /*metadata=*/true

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, it's just the comment as to what the parameter is.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, yes. Misread it.


if (meta_encryptor_cache_[index] == nullptr) {
meta_encryptor_cache_[index] = AesEncryptor::Make(alg_id, key_len, true);
if (encryptor_cache_.find(cache_key) == encryptor_cache_.end()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is essentially the same as before but in find/end format, right? Or is there more to it?
Let's add a comment either way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the same. Added comment.

ParquetCipher::type alg_id, int32_t key_size) {
auto key_len = static_cast<int32_t>(key_size);
int index = MapKeyLenToEncryptorArrayIndex(key_len);
uint64_t cache_key = MakeCacheKey(alg_id, key_len, /*metadata=*/false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! We need a comment here since it's the critical part that changed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. Also check the comment in the .h file

Copy link
Collaborator

@avalerio-tkd avalerio-tkd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the changes and the testing.

@sofia-tekdatum sofia-tekdatum merged commit 5fe6f2e into dev_phase2 Aug 26, 2025
16 of 63 checks passed
@sofia-tekdatum sofia-tekdatum deleted the fix_encryptor_cache branch August 28, 2025 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants